<template>
  <home-card title="我的申报" isDark class="home-apply-wrap" v-loading="table.loading">
    <div v-for="item in table.data" :key="item.id" class="home-apply" @click="gotoDetail(item)">
      <div class="home-apply-title">
        {{ item.name }}
      </div>
      <div class="home-apply-footer">
        <span class="time">{{ parseTime(item.createTime, "{y}/{m}/{d} {h}:{i}") }}</span>
        <!-- <el-tag class="home-apply-status">{{  }}</el-tag> -->
        <dict-tag
            :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS"
            :value="item.status"
          />
      </div>
    </div>
    <pagination v-show="table.total > 0" :total="table.total" :page.sync="table.page.pageNo"
      :limit.sync="table.page.pageSize" layout="prev, pager, next" :background="false" align="center" @pagination="getListData" />
  </home-card>
</template>

<script>
import { getMyProcessInstancePage } from "@/api/bpm/processInstance";
import HomeCard from "./home-card.vue";

export default {
  components: { HomeCard },
  data() {
    return {
      // list: [],
      table: {
        data: [],
        loading: false,
        total: 0,
        page: {
          pageNo: 1,
          pageSize: 10,
        },
      },
    };
  },
  created() {
    this.getListData();
  },
  methods: {
    getListData() {
      getMyProcessInstancePage({
        ...this.table.page,
      },).then((res) => {
          const { list, total } = res?.data || {};
          this.table.data = list || [];
          this.table.total = total || 0;
        })
        .finally(() => {
          this.table.loading = false;
        });
    },
    gotoDetail(item) {
      this.$router.push({ path: "/bpm/process-instance/detail", query: { id: item.id } });
    },
  },
};
</script>

<style lang="scss" scoped>
.home-apply-wrap {
  // max-height: 100%;
  // overflow-y: auto;
  font-size: 14px;

  :deep(.pagination-container) {
    background-color: transparent;
  }
  ::v-deep {
    .el-pagination button, .el-pager li {
      background-color: transparent;
    }
  }
}

.home-apply {
  padding: 10px;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;

  +.home-apply {
    margin-top: 16px;
  }

  &-title {
    font-size: 14px;
    font-weight: 500;
    color: #3f8ff6;
    line-height: 22px;
  }

  &-desc {
    font-size: 12px;
    line-height: 16px;
    margin-top: 10px;
    display: flex;
    align-items: center;

    .process {
      color: #a7aaae;
      display: inline-block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 80%;
      margin-right: 4px;
    }

    .count {
      // font-size: 14px;
      font-weight: bold;
    }
  }

  &-footer {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .time {
      font-size: 12px;
      color: #a7aaae;
      line-height: 16px;
      width: 130px;
    }
  }

}
</style>
